package org.example.sudoku;

import java.util.ArrayList;

import android.app.Activity;
//import android.app.ListActivity;
//import android.widget.ArrayAdapter;
//import android.widget.ListView;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.content.Intent;
//import java.util.ArrayList;



public class Sudoku extends Activity implements OnClickListener {
    /** Called when the activity is first created. */
	private ArrayList<String> scanList = new ArrayList<String>();
    @Override
    
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        setContentView(R.layout.main);
        
     // Set up click listeners for all the buttons
        
        View exitButton = findViewById(R.id.exit_button);
        exitButton.setOnClickListener(this);
        View scanButton = findViewById(R.id.scan_button);
        scanButton.setOnClickListener(this);
        View editButton = findViewById(R.id.about_button);
        editButton.setOnClickListener(this);
       
    }
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.scan_button:
			Intent intent = new Intent("com.google.zxing.client.android.SCAN");
			intent.putExtra("com.google.zxing.client.android.SCAN.SCAN_MODE", "ONE_D_MODE");
			startActivityForResult(intent, 0);
		break;
		case R.id.about_button:

			Intent about = new Intent(this.getApplicationContext(),About.class);
		
			Bundle b = new Bundle();

			b.putStringArrayList("key", scanList);
		
			about.putExtras(b);
			
			startActivityForResult(about, 0);
		break;
		case R.id.exit_button:
			finish();
		break;
	

					}
				}
	

	
	public void onActivityResult(int requestCode, int resultCode, Intent intent) {
	    if (requestCode == 0) {
	        if (resultCode == RESULT_OK) {
	            String contents = intent.getStringExtra("SCAN_RESULT");
	            // Handle successful scan
				Intent result = new Intent(this.getApplicationContext(),Result.class);
				Bundle b = new Bundle();
				b.putString("content",contents);
				result.putExtras(b);
				startActivityForResult(result, 0);
				
			

	        } else if (resultCode == RESULT_CANCELED) {
	            // Handle cancel
	        }
	    }
	}
	
	protected void onActivityResult1(int requestCode, int resultCode, Intent getListIntent){
		if (resultCode == RESULT_OK) {
    	Bundle b = getIntent().getExtras();	
    	
    	scanList = b.getStringArrayList("key");
    	
        } else if (resultCode == RESULT_CANCELED) {
            // Handle cancel
        }
    }
}


	





